/**
 * Created by AllanXu on 7/25/2016.
 */
define(function (require) {
	var Vue = require('vue'),
        Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities');

	var app = new Vue({
		el: '#marriage_class',
		data: {
			pageCount: '',
			pageno: 1,
            renderObj: {
                listArr: []
            },
            bottomTxt: ''
		},
		methods:{
			init: function () {
				// 恋爱课堂
				_(Config.SERVICE.INDEX.MARRIAGECLASS,{
					"pagesize": 10,
					"pageno": app.pageno
				},function(data) {
                    console.log(data);
                    if(app.pageno == 1){
                        app.renderObj.listArr = data.pageitems;
                        app.pageCount = data.pagecount;
                    }else{
                        app.renderObj.listArr = app.renderObj.listArr.concat(data.pageitems);
                    }
                });
			},
			// 活动详情
			goDetail: function(url){
				location.href = url;
			}
		}
	});
	app.init();

	window.onscroll = function(){
        var scrolltop = document.body.scrollTop | document.documentElement.scrollTop;
        var clientHeight = document.documentElement.clientHeight;
        if(scrolltop + clientHeight  == document.body.clientHeight){
            if (app.pageno <= app.pageCount){
                app.pageno++;
                app.init();
            }else{
                app.bottomTxt = '到底儿了~';
            }
        }
    }
});